import sys
import logging                                                                  # запись логов

from PyQt5.QtWidgets import *

class Label(QLabel):
    def __init__(self, parent=None):
        super().__init__()
        
    def mouseMoveEvent(self, event):
        file=QTemporaryFile()
        if (file.open()):
            url = Qurl.fromLocalFile(file.fileName())
            file.write(text().toUtf8())
            file.close()

            drag = QDrag()
            mimeData = QMimeData()
            mimeData.setUrls(url)
            drag.setMimeData(mimeData)
            drag.exec_(Qt.CopyAction)
            
if __name__ == '__main__':                                                      

    app = QApplication(sys.argv)
    label = Label()
    label.setText("foo bar");
    label.show();
    sys.exit(app.exec_())                                                       # Запускаем цикл обработки событий

